package com.j180.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
//@Component
public class ShowTimeAdvice {

    @Pointcut("execution(* com.j180.dao.impl.*.*(..))")
    private void timePointCut(){}

    @Around("timePointCut()")
    public void showTime(ProceedingJoinPoint proceedingJoinPoint){

        long startTime = System.currentTimeMillis();

        try {
            Object obj = proceedingJoinPoint.proceed();
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }
        long endTime = System.currentTimeMillis();

        System.out.println(proceedingJoinPoint.getSignature().getName()+"执行的时间为"+(endTime-startTime));
    }
}
